package com.ruoyi.project.system.service.impl;

import java.util.List;
import java.util.Map;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.MiddleTableData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.system.mapper.TSingleselMapper;
import com.ruoyi.project.system.domain.TSinglesel;
import com.ruoyi.project.system.service.ITSingleselService;

/**
 * 单选题库Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-05-09
 */
@Service
public class TSingleselServiceImpl implements ITSingleselService 
{
    @Autowired
    private TSingleselMapper tSingleselMapper;

    /**
     * 查询单选题库
     * 
     * @param singleselId 单选题库ID
     * @return 单选题库
     */
    @Override
    public TSinglesel selectTSingleselById(Integer singleselId)
    {
        return tSingleselMapper.selectTSingleselById(singleselId);
    }

    /**
     * 查询单选题库列表
     * 
     * @param tSinglesel 单选题库
     * @return 单选题库
     */
    @Override
    public List<TSinglesel> selectTSingleselList(TSinglesel tSinglesel)
    {
        return tSingleselMapper.selectTSingleselList(tSinglesel);
    }

    /**
     * 新增单选题库
     * 
     * @param tSinglesel 单选题库
     * @return 结果
     */
    @Override
    public int insertTSinglesel(TSinglesel tSinglesel)
    {
        tSinglesel.setCreateTime(DateUtils.getNowDate());
        return tSingleselMapper.insertTSinglesel(tSinglesel);
    }

    /**
     * 修改单选题库
     * 
     * @param tSinglesel 单选题库
     * @return 结果
     */
    @Override
    public int updateTSinglesel(TSinglesel tSinglesel)
    {
        return tSingleselMapper.updateTSinglesel(tSinglesel);
    }

    /**
     * 批量删除单选题库
     * 
     * @param singleselIds 需要删除的单选题库ID
     * @return 结果
     */
    @Override
    public int deleteTSingleselByIds(Integer[] singleselIds)
    {
        deleteMiddle(singleselIds[1],singleselIds[0]);
        return tSingleselMapper.deleteTSingleselByIds(singleselIds);
    }

    /**
     * 删除单选题库信息
     * 
     * @param singleselId 单选题库ID
     * @return 结果
     */
    @Override
    public int deleteTSingleselById(Integer singleselId)
    {
        return tSingleselMapper.deleteTSingleselById(singleselId);
    }

    @Override
    public int addMiddle(Integer  subject_id ,Integer multiSel_id) {
        MiddleTableData middleTableData = new MiddleTableData();
        return tSingleselMapper.addMiddle(middleTableData.FZMap(subject_id,multiSel_id));
    }

    @Override
    public int updateMiddle(Integer  subject_id ,Integer multiSel_id,String courseName) {
        MiddleTableData middleTableData = new MiddleTableData();
        Map map = middleTableData.FZMap(subject_id, multiSel_id);
        map.put("courseName",courseName);
        return tSingleselMapper.updateMiddle(map);
    }

    @Override
    public int deleteMiddle(Integer  subject_id ,Integer multiSel_id) {

        MiddleTableData middleTableData = new MiddleTableData();
        return tSingleselMapper.deleteMiddle(middleTableData.FZMap(subject_id,multiSel_id));
    }
}
